﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PMS.BusinessFacade;
using PMS.EntityManage;
using PMS.Common;
using PMS.EntityQuery;
using System.Data.SqlClient;
using System.Collections.Generic;

using BusinessFacade;
using EntityManage;
using Microsoft.Reporting.WebForms;
public partial class Modules_Personal_PerfEvaluateIndividualReport : System.Web.UI.Page
{
    IPerf_Personal_EvaluateHandler evaluateHandler = new Perf_Personal_EvaluateManage();
    IPerf_Personal_EvaluateDtlHandler evaluateDtlHandler = new Perf_Personal_EvaluateDtlManage();

    ISys_OrganizationHandler organizationHandler = new Sys_OrganizationManage();

    IPerf_Personal_TargetOwnerHandler targetOwnerHandler = new Perf_Personal_TargetOwnerManage();
    DataBase db = new DataBase();

    ISys_UserHandlerExt userHandlerExt = new Sys_UserManageExt();
    IPerf_Personal_EvaluateHandlerExt evaluateHandlerExt = new Perf_Personal_EvaluateManageExt();
    IPerf_Personal_FinalAssignHandler finalAssignHandler = new Perf_Personal_FinalAssignManage();

    IPerf_Personal_ApprovalHandler erfApprovalHandler = new Perf_Personal_ApprovalManage();
    IReportHandler rptHandler = new ReportManage();


    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillDDl();
             PreviewReport();
        }
    }

    private void FillDDl()
    {
      
    }

    #region Preview Report
    private void PreviewReport()
    {




        string whereClause = " 1=1 ";
        SqlParameter[] parms = null;
        ProcessParms(ref whereClause, ref parms);

        whereClause += " and pa.Target_User_ID=" + int.Parse(Session["CurrentUserID"].ToString());
        rptViewer.LocalReport.ReportPath = "Modules/Personal/rptPerfEvaluateOrgAll.rdlc";

        rptViewer.LocalReport.DataSources.Clear();
        DataTable dt = rptHandler.GetPerfEvaluateOrgAllData(whereClause, parms, " Begin_Time asc ");
        if (dt != null && dt.Rows.Count > 0)
        {
            rptViewer.Visible = true;
            lblNoRecord.Visible = false;
            ReportDataSource datasource = new ReportDataSource("dsPerfEvaluateOrgAll_DataTable1", dt);
            rptViewer.LocalReport.DataSources.Add(datasource);

            ReportParameter[] parameters = new ReportParameter[3];
            parameters[0] = new ReportParameter("DateFrom", Convert.ToDateTime(dt.Rows[0]["Begin_Time"].ToString()).ToString("yyyy-MM-dd"));
            parameters[1] = new ReportParameter("DateTo", Convert.ToDateTime(dt.Rows[0]["End_Time"].ToString()).ToString("yyyy-MM-dd"));
            parameters[2] = new ReportParameter("ReportTitle", "个人绩效成绩");
            rptViewer.LocalReport.SetParameters(parameters);
            rptViewer.LocalReport.Refresh();
        }
        else
        {
            rptViewer.Visible = false;
            lblNoRecord.Visible = true;
        }

    }
    #endregion


    /// <summary>
    /// 条件参数处理
    /// </summary>
    /// <param name="whereClause"></param>
    /// <param name="parms"></param>
    private void ProcessParms(ref string whereClause, ref SqlParameter[] parms)
    {
      //
    }


    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //ViewState["Title"] = ddlTitle.SelectedValue;


        PreviewReport();
    }
}
